package cn.com.guage.dtm.huawei;

import java.util.Arrays;

public class guage_排序 {
    public static void main(String[] args) {
        int[] array = {121,32,343,11,454,676,3434,22,55,3434,323,3,323,656,1};
        sort2(array);
    }

    /**
     * 通过 Arrays.sort实现排序
     * @param array
     */
    private static void sort1(int[] array) {
        Arrays.sort(array);
        System.out.println(Arrays.toString(array));
    }

    /**
     *  实现冒泡排序
     * @param array
     */
    private static void sort2(int[] array) {
        for (int i = 0; i < array.length; i++) {
            for (int j = i + 1; j < array.length; j++) {
                int min = array[i];
                int max = array[j];
                if (min > max) {
                    int temp = array[i];
                    array[i] = array[j];
                    array[j] =  temp;
                }
            }
        }
      System.out.println(Arrays.toString(array));
    }
}
